const { Category } = require('../../../model/category');
const { ChildCategory } = require('../../../model/childCategory');

module.exports = (req, res) => {
  const { id } = req.query
  const callback = (err, row) => {
    console.log(row)
    if(!err) {
      res.json({
        message: '删除成功!'
      })
    } else {
      res.status(403)
      res.json({
        log: err,
        message: '删除失败！'
      })
    }
  }
  // 先删所有子菜单
  ChildCategory.remove({parent: id}, (err) => {
      Category.findOneAndRemove({_id: id}, callback)
  })
}